<template>
    <div id="tmpl">

        <div id="desc">
            <div class="tilte">
                <h4>{{photoinfo.title}}</h4>
                <p>
                    {{photoinfo.add_time | datefmt("YYYY-MM-DD hh:mm:ss")}}

                    {{photoinfo.click}}次点击
                </p>
                <p class="line"></p>
            </div>
            <div class="mui-content">
                <ul class="mui-table-view mui-grid-view mui-grid-9">
                    <li v-for="(item, index) in list" class="mui-table-view-cell mui-media mui-col-xs-4 mui-col-sm-3">
                        <img class="preview-img"  :src="item.src" height="100" @click="$preview.open(index, list)" alt=""/>
                    </li>
                </ul>
            </div>

           <p v-html="photoinfo.content"></p>
        </div>

        <div id="comment">
            <comment :id="id"></comment>
        </div>
    </div>
</template>

<script>
    import comment from './../../subcom/comment.vue';
    import common from './../../../kits/common.js';
    import { Toast } from 'mint-ui';
    export default{
      components:{
          comment
      },
      data(){
          return{
              id:0,
              photoinfo: {
//                  "id": 43,
//                  "title": "清新有活力的公寓设计 用色彩焕然一新",
//                  "click": 3,
//                  "add_time": "2017-07-02T13:36:02.000Z",
//                  "content": "Widawscy Studio为华沙的一处公寓做了设计，初看是最为保守的白底搭配木质元素，细看发现每个空间都被赋予了不同的色彩。面积最大的公共空间，包括客厅，餐厅和厨房采用了黄色的，让家人相聚时始终保持一颗愉快的心情，沉稳的灰色的主卧，轻快的蓝色调卧室，被芥末绿铺满的卫生间，减少配饰的使用 ，用色彩焕然一新。"
              },
              list:[]
          }
      },
      created(){
          this.id = this.$route.params.id;
          this.getphotoinfo();
          this.getlist();
      },
        methods:{
            getphotoinfo(){
                var url = common.apidomain + '/api/getimageInfo/' + this.id;
                this.$http.get(url).then(function(response){
                    var data = response.body;
                    if(data.status != 0){
                        Toast(data.message);
                        return;
                    }
                    this.photoinfo = data.message[0];
                })
            },
            getlist(){
                var url = common.apidomain + '/api/getthumimages/' + this.id;
                this.$http.get(url).then(function(response){
                    if(response.body.status != 0){
                        Toast(response.body.message);
                        return;
                    }
                    response.body.message.forEach(function(item){
                        var img = document.createElement('img');
                        img.src = item.src
                        item.h = img.height;
                        item.w = img.width;
                    });
                    this.list = response.body.message;
                })
            }
        }
    }
</script>

<style scoped>
    #desc{
        padding: 10px;
    }
    .tilte h4{
        color: #0094ff;
    }
    .tilte p{
        color: #c0c0c0;
        margin-top: 10px;
    }
    .tilte .line{
        width: 100%;
        height: 1px;
        border-bottom: 1px solid #c0c0c0;
    }
    .mui-grid-view.mui-grid-9{
        background-color: #fff;
        border-top: 0px;
        border-left: 0px;
    }
    .mui-grid-view.mui-grid-9 .mui-table-view-cell{
        border-right: 0px;
        border-bottom: 0px;
    }
    .mui-content img{
        width: 100px;
        height: 100px;
    }
    .mui-content img{
        display: inline-block;
    }
</style>